//
//  TSBaseTabBarController.m
//  TaShuo
//
//  Created by N-X on 2018/1/17.
//  Copyright © 2018年 MRNAN. All rights reserved.
//
/*
 UIImageRenderingModeAutomatic // 根据图片的使用环境和所处的绘图上下文自动调整渲染模式，默认就是蓝色
 UIImageRenderingModeAlwaysOriginal // 始终绘制图片原始状态，不使用Tint Color
 UIImageRenderingModeAlwaysTemplate // 始终根据Tint Color绘制图片，忽略图片的颜色信息
 */

#import "TSBaseTabBarController.h"
#import "TSRootNavigationController.h"

@interface TSBaseTabBarController ()

@end

@implementation TSBaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.translucent = NO; //设置不透明
    [self.tabBar setTintColor:NX_ColorFromRGB(137, 179, 116)];
    self.tabBar.barTintColor = [UIColor blackColor];
    
    NSString * path = [[NSBundle mainBundle] pathForResource:@"Controllers.plist" ofType:nil];
    NSArray * controllers = [NSArray arrayWithContentsOfFile:path];
    //    NXLog(@"controllers:%@",controllers);
    NSMutableArray * viewControllers = [NSMutableArray arrayWithCapacity:4];
    for (NSDictionary * dict in controllers) {
        NSString * image = dict[@"image"];
        NSString * title = dict[@"title"];
        NSString * className = dict[@"className"];
        Class class = NSClassFromString(className);
        UIViewController * viewController = [[class alloc]init];
        viewController.title = title;
        TSRootNavigationController * navigation = [[TSRootNavigationController alloc]initWithRootViewController:viewController];
        navigation.tabBarItem.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",image]];
        navigation.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@",image]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        [viewControllers addObject:navigation];
        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:NX_ColorFromRGB(137, 179, 116)} forState:UIControlStateSelected];
    }
    self.viewControllers  = viewControllers;
}


@end
